home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6071 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: ix.netcom.com!netnews
  2. From: swampwiz@ix.netcom.com(Jean P. Laborde )
  3. Newsgroups: comp.lang.c++
  4. Subject: OOPS! - Re: How to delete array of pointers?
  5. Date: 11 Feb 1996 14:42:27 GMT
  6. Organization: Netcom
  7. Message-ID: <4fkv8j$kb@cloner3.netcom.com>
  8. References: <4fgvsu$5q4@eng_ser1.erg.cuhk.hk> <4fi8rd$738@reader2.ix.netcom.com>
  9. NNTP-Posting-Host: ix-no1-18.ix.netcom.com
  10. X-NETCOM-Date: Sun Feb 11  6:42:27 AM PST 1996
  11.  
  12. OOPS !
  13.  
  14. In <4fi8rd$738@reader2.ix.netcom.com> swampwiz@ix.netcom.com(Jean P.
  15. Laborde ) writes: 
  16. >
  17. >In <4fgvsu$5q4@eng_ser1.erg.cuhk.hk> ywleung@cs.cuhk.hk (Marty McFly)
  18. >writes: 
  19. >>
  20. >>If I write the following code in a function:
  21. >>
  22. >>    int** ptr;
  23. >>    ptr = new int*[1000];
  24. >>
  25. >>Is this code means allocating 1000 integer pointers which is pointed
  26. >by ptr?
  27. >>And then somehow I assign integer variable to ptr[0], ptr[1], ... and
  28. >so on.
  29. >>So at the end of the function, how can I reclaim just those pointers?
  30.  
  31. >The key
  32. >>point is that those integer variable assigned to the pointers should
  33. >not be 
  34. >>deleted.
  35. >>
  36. >>Regards,
  37. >>Marty McFly.
  38. >
  39.  
  40. I mistakenly said:
  41.  
  42. >how about:
  43. >
  44. >for(int i=0;i<1000;i++)
  45. >    delete ptr[i];
  46. >delete ptr;
  47. >
  48. >
  49.  
  50. I should have said at the last line
  51.  
  52. delete ptr [];
  53.  
  54.  
  55.